import http from '@/utils/http'

const BASE_URL = '/vending/material'

export interface MaterialResp {
  id: string
  deviceTypeId: string
  materialName: string
  materialCode: string
  materialType: string
  description: string
  qty: string
  qtyUnit: string
  warnQty: string
  consumeRate: string
  inventoryCheck: string
  inventoryConsume: string
  status: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface MaterialDetailResp {
  id: string
  deviceTypeId: string
  materialName: string
  materialCode: string
  materialType: string
  description: string
  qty: string
  qtyUnit: string
  warnQty: string
  consumeRate: string
  inventoryCheck: string
  inventoryConsume: string
  status: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface MaterialQuery {
  deviceTypeId: string
  materialName: string
  materialType: string
  status: string
  sort: Array<string>
}
export interface MaterialPageQuery extends MaterialQuery, PageQuery {}

/** @desc 查询原料列表 */
export function listMaterial(query: MaterialPageQuery) {
  return http.get<PageRes<MaterialResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询原料详情 */
export function getMaterial(id: string) {
  return http.get<MaterialDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增原料 */
export function addMaterial(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改原料 */
export function updateMaterial(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除原料 */
export function deleteMaterial(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}
